package com.scy.java.io.file;

import java.io.File;

//遍历目录
public class FIleListDemo {
    public static void main(String[] args) {
        File file = new File("d:/");
        System.out.println("文件名称\t\t文件类型\t\t文件大小");
        //调用list方法
        String[] fileList = file.list(new ImageFilter());
        //遍历返回的字符串数组
        for (int i = 0; i < fileList.length; i++) {
            System.out.print(fileList[i]+"\t\t");
            System.out.print(
                    (new File("d:/",fileList[i]))
                            .isFile()?"是文件\t\t":"文件夹\t\t");
            System.out.println((new File("d:/",fileList[i])).length()+"字节");

        }
    }
}
